<?php
include_once('common/header.php');	
if($AppUI->id <= 0 || !isset($_SERVER['HTTP_REFERER'])) {	
	$arrJson = array('error'=>1,'msg'=>$arrError[1]);
	echo $objRequest->getParam('callback') . '(' . Zend_Json::encode($arrJson) . ')';
	exit();
}
$intAjax	= $objRequest->getParam('aj', 0);
if($intAjax > 0) {
	$intPage	= $objRequest->getParam('npage', 1);
	$intLimit	= NOTIFICATION_LIMIT;
	$intOffset	= ($intPage-1)*$intLimit;
	$intTotal	= 0;
	$objNotify	= new Notification();
	$arrResult	= $objNotify->getNotifyByUserId($AppUI->id,$intOffset,$intLimit,$intTotal);
	$this->view->intTotalPage	= ceil($intTotal / $intLimit);
	$this->view->intPage 		= $intPage;
	$this->view->arrResult 		= $arrResult;
	$this->view->intAjax		= $intAjax;	
	$objNotify->updateUnread($AppUI->id);
}
$objView 	= Zend_Registry::get('objView');
if($intAjax == 2) {
	$strData	= $objView->fetch('ajax/notification-item.tpl');
} else {
	$strData	= $objView->fetch('ajax/notification.tpl');
}
$arrJson = array('error'=>0,'msg'=>$strData);
echo $objRequest->getParam('callback') . '(' . Zend_Json::encode($arrJson) . ')';
exit();
?>